﻿using Microsoft.Xna.Framework.Content;

namespace TextListLib
{
    /// <summary>
    /// This is the last stage of a custom Content Pipeline extension. This is what ContentManager calls to load
    /// your content when you call ContentManager.Load&lt;T&gt;. It derives from ContentTypeReader&lt;T&gt; and
    /// the way it reads in data must mirror the way data was written out by the ContentTypeWriter or else you
    /// will get weird errors and (likely) exceptions.
    /// </summary>
    public class TextListReader : ContentTypeReader<TextList>
    {
        /// <summary>
        /// This is what ContentManager calls to read in your content. In our case we call a special version of
        /// the TextList constructor that takes a ContentReader. You could implement the ContentReader here, but
        /// I find that it makes more sense (to me) to have it done inside the class that's reading it in. That
        /// keeps everything nice and tidy inside its class. Just a personal preference though.
        /// </summary>
        /// <param name="input">
        /// The ContentManager-supplied input. ContentManager takes care of opening up the XNB file and giving
        /// you a ContentReader that's all set to read in your content.
        /// </param>
        /// <param name="existingInstance">I'm sure this has a purpose, but in my tests it's just been null so I ignore it.</param>
        /// <returns>The content read in from the XNB file.</returns>
        protected override TextList Read(ContentReader input, TextList existingInstance)
        {
            return new TextList(input);
        }
    }
}
